import { Component, OnInit } from '@angular/core';
import { PageService } from 'app/utils/page.service'
import { UserManageService } from 'app/services/manage/user-manage.service'

@Component({
  selector: 'app-user-manage',
  templateUrl: './user-manage.component.html',
  styleUrls: ['./user-manage.component.less']
})
export class UserManageComponent implements OnInit {
  dataSet: Array<Object> = [];
  constructor(
    private page: PageService,
    private userManageService: UserManageService
  ) { }


  /**
   * 初始化
   */
  ngOnInit() {
    this.refreshData();
  }

  /**
   * 更新数据
   */
  refreshData() {
    this.userManageService.getUsers(this.page)
      .then((data: Array<Object>) => data.map((x: any) => ({
        id:x.id,
        username: x.get('username'),
        realname: x.get('realname'),
        email: x.get('email'),
        phonenumber: x.get('phonenumber')
      })))
      .then(data => this.dataSet = data)
  }

  deleteUser(){
  }
}
